package com.jiyun.controller;

import com.jiyun.pojo.User;
import com.jiyun.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    //查询所有用户
    @GetMapping("/findAll")
    public List<User> findAll(){
        return userService.findAll();
    }

    //添加
    @GetMapping("/add")
    public void add(User user){
         userService.add(user);
    }

    //回显
    @GetMapping("/findById")
    public User findById(Integer id){
        return userService.findById(id);
    }

    //修改
    @GetMapping("/update")
    public void update(User user){
        userService.update(user);
    }

    //修改
    @GetMapping("/delete")
    public void delete(Integer id){
        userService.delete(id);
    }
}
